//笔试强训: mari和shiny

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n = 0; string str;
    cin >> n >> str;
    
    long long s = 0, sh = 0, shy = 0;
    for(int i = 0; i < n; i++)
    {
        if(str[i] == 's') s++;
        else if(str[i] == 'h') sh += s;
        else if(str[i] == 'y') shy += sh;
    }

    cout << shy << endl;
}